package pacificlms.Verifiable.Database;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.JOptionPane;
import pacificlms.MasterConnection;
import pacificlms.Verifiable.*;

/**
 * Resource is a child of VerifiableObject dealing with Resources
 * Since all fields are get/set they are not individually commented
 * @author Brian Hume
 */
public class Resource extends VerifiableObject
{
    @Override
    public String TableName() {
        return "Resource";
    }
    
    private String ResourceCode;
    @VerifyAnnotation(ApplicationName="Resource Code", DBName="ResourceCode",  Type=TypeEnum.STRING, Length=50, PrimaryKey=true)
    public String ResourceCode(String value)
    {
        return ResourceCode = StandardProcess(ResourceCode, value);
    }
    
    
    private String Title;
    @VerifyAnnotation(ApplicationName="Title", DBName="Title",  Type=TypeEnum.STRING, Length=250)
    public String Title(String value)
    {
        return Title = StandardProcess(Title, value);
    }
    
    private String SubTitle;
    @VerifyAnnotation(ApplicationName="Sub-Title", DBName="SubTitle",  Type=TypeEnum.STRING, Length=250)
    public String SubTitle(String value)
    {
        return SubTitle = StandardProcess(SubTitle, value);
    }
    
    
    private String Keywords;
    @VerifyAnnotation(ApplicationName="Keywords/Tags", DBName="Keywords",  Type=TypeEnum.STRING, Length=250)
    public String Keywords(String value)
    {
        return Keywords = StandardProcess(Keywords, value);
    }
    
    
    private String Type;
    @VerifyAnnotation(ApplicationName="Resource Type", DBName="Type",  Type=TypeEnum.LOOKUP, Length=20, LookupDBTable="ResourceType", LookupDBField="Type")
    public String Type(String value)
    {
        return Type = StandardProcess(Type, value);
    }
    
    
    private String ForiegnOwner;
    @VerifyAnnotation(ApplicationName="Foreign Owner", DBName="ForeignOwner",  Type=TypeEnum.LOOKUP, Length=20, LookupDBTable="Member", LookupDBField="IdentityNumber", NotNull=false)
    public String ForiegnOwner(String value)
    {
        return ForiegnOwner = StandardProcess(ForiegnOwner, value);
    }
    
    private String Actors;
    @VerifyAnnotation(ApplicationName="Actors", DBName="Actors",  Type=TypeEnum.STRING, Length=2000, NotNull=false)//VHS/DVS/BRD
    public String Actors(String value)
    {
        return Actors = StandardProcess(Actors, value);
    }

    private String Songs;
    @VerifyAnnotation(ApplicationName="Songs", DBName="Songs",  Type=TypeEnum.STRING, Length=2000, NotNull=false)//Music CD/Tape
    public String Songs(String value)
    {
        return Songs = StandardProcess(Songs, value);
    }
    
    private String Information;
    @VerifyAnnotation(ApplicationName="Information", DBName="Information",  Type=TypeEnum.STRING, Length=2000, NotNull=false)//Other resource
    public String Information(String value)
    {
        return Information = StandardProcess(Information, value);
    }

    private String IssueNumber;
    @VerifyAnnotation(ApplicationName="Issue Number", DBName="IssueNumber",  Type=TypeEnum.NUMERICSTRING, Length=11, NotNull=false)//magazine
    public String IssueNumber(String value)
    {
        return IssueNumber = StandardProcess(IssueNumber, value);
    }
    
    @Override
    public String toString()
    {
        return "Code: ["+ResourceCode + "] " + Title;
    }
    
    public boolean IsReference()
    {
        if(Type.equalsIgnoreCase("magazine") || Type.equalsIgnoreCase("paper"))
            return true;
        return false;
    }
}
